package com.yuhao.init.utils;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.jetbrains.annotations.NotNull;

/**
 * @Author: yuhao
 * @Date: 2024/5/3 16:56
 */

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Usp implements Comparable<Usp> {
    private int id;
    private int age;
    private String [] name;

    @Override
    public int compareTo(@NotNull Usp o) {
        if ((this.age - o.age)!=0){
            return this.age - o.age;
        }
        return this.id- o.id;
    }

    public static void main(String[] args) {
        String str = "A,B,C";
        String[] array = str.split(",");

        // 构建数组的字符串表示
        StringBuilder sb = new StringBuilder("[");
        for (int i = 0; i < array.length; i++) {
            sb.append("'").append(array[i].trim()).append("'");
            if (i < array.length - 1) {
                sb.append(",");
            }
        }
        sb.append("]");
        // 输出结果
        System.out.println(sb.toString());
    }
}
